package zFactory;

import org.eclipse.emf.common.util.EList;

import node1.AbstractTask;
import pUNB.PUNB;
import pUNB.PUNBFactory;
import pUNB.Task;
import genArchi.Node;

public class NodePUNB implements NodeInterface {

	/**
	 * 
	 */
	private EList<AbstractTask> l_tasks;
	private boolean enableCreate;
	/**
	 * Constructor
	 */
	public NodePUNB(EList<AbstractTask> l_tasks, boolean enableCreate) 
	{
		this.l_tasks = l_tasks;
		this.enableCreate = enableCreate;
	}
	
	@Override
	public Node createNode() {

		PUNB pu = PUNBFactory.eINSTANCE.createPUNB();

		/**/
		for (AbstractTask t : l_tasks) {

			/* Create local tasks, and set attributes */
			Task lt = PUNBFactory.eINSTANCE.createTask();
			lt.setPeriod(t.getPeriod());
			lt.setWcet(t.getWcet());

			/* Add to list of tasks*/
			pu.getTasks().add(lt);
		}

		return pu;
	}

	@Override
	public String getNodeName() 
	{
		return "pUNB.impl.PUNBImpl";
	}

	@Override
	public void update(Node node) {}

	@Override
	public boolean isEnable() 
	{
		return this.enableCreate;
	}

}
